package com.shuo.dsa.leetcode;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by shuoGG on 2018/10/9 0009
 */
public class SingleNumber2 {
    public int singleNumber(int[] A) {
        Map<Integer, Integer> map = new HashMap<>();
        for (int i : A) {
            map.merge(i, 1, (a, b) -> a + b);
        }
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (entry.getValue()==1)
                return entry.getKey();
        }
        return 0;
    }
}
